package main

import (
	"database/sql"
	"errors"
)

func main() {
	db, err := sql.Open("mysql", "root:xavier@tcp(127.0.0.1:3306)/test")

	if err != nil {
		return
	}

	var username string

	//查询时可能遇到遇到没有查到这个结果集,("sql:now rows in result set"),属于正常错误，不需要往上抛
	err = db.QueryRow("select pass from test").Scan(&username)

	switch {
	case err == sql.ErrNoRows:
	case err != nil:
		errors.Wrap(err, "the query may has error")
	}

}
